from pandac.PandaModules import *
from pr3da.transition.Transition import Pr3daTransition
from direct.interval.IntervalGlobal import *
from direct.interval.LerpInterval import LerpPosInterval

class FlyTransition(Pr3daTransition):
  def __init__(self):
    super(FlyTransition, self).__init__()

  def doTransition(self, np_pos):
    p = Parallel()
    for np, pos in np_pos.iteritems():
      p.append(LerpPosInterval(np, 1.0, Point3(*pos), blendType = 'easeInOut'))
    p.start()


#TODO: find out why this doesn't work!
class FadeTransition(Pr3daTransition):
  def __init__(self):
    super(FadeTransition, self).__init__()

  def doTransition(self, np_pos):
    main = Sequence()
    pfout = Parallel()
    pmove = Parallel()
    pfin = Parallel()

    for np, pos in np_pos.iteritems():
      np.setTransparency(True)
      pfout.append(LerpColorScaleInterval(np, 1.0, Vec4(1,1,1,0),Vec4(1,1,1,1)))
      pmove.append(LerpPosInterval(np, 0.0, Point3(*pos)))
      pfin.append(LerpColorScaleInterval(np, 1.0, Vec4(1,1,1,1),Vec4(1,1,1,0)))
    
    main.append(pfout)
    main.append(pmove)
    main.append(pfin)
    
    main.start()


